package com.pubinfo.passbook.common.model.http;

import io.swagger.models.auth.In;

import javax.xml.crypto.Data;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

public class GetTime {
  public static String getMSGID(String servicename, Date date) {
    SimpleDateFormat f = new SimpleDateFormat("yyyyMMddHHmmssSSS");
    return "CTECO_OP_" + servicename + "_" + f.format(date) + rand();
  }
  
  public static String getSENDTIME(Date date) {
    SimpleDateFormat f = new SimpleDateFormat("yyyyMMddHHmmss");
    return f.format(date);
  }
  
  private static String rand() {
    String str = "";
    Random rand = new Random();
    for (int i = 0; i < 5; i++) {
      int num = rand.nextInt(3);
      switch (num) {
        case 0:
          char c1 = (char) (rand.nextInt(26) + 'a');//生成随机小写字母
          str += c1;
          break;
        case 1:
          char c2 = (char) (rand.nextInt(26) + 'A');//生成随机大写字母
          str += c2;
          break;
        case 2:
          str += rand.nextInt(10);//生成随机数字
      }
    }
    return str;
  }
}
